<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <title>后盾人</title>
</head>

<body></body>
<script>
  function unique(arr) {
    let newArr = []
    let obj = {}
    arr.forEach(item => {
      if (typeof item !== 'object') {
        if (newArr.indexOf(item) === -1) {
          newArr.push(item)
        }
      } else {
        let str = JSON.stringify(item)
        if (!obj[str]) {
          newArr.push(item)
          obj[str] = 1
        }
      }

    })
    console.log(obj);
    return newArr
  }
  console.log(unique([123, 123, [1, 2, 3], [1, '2', 3], [1, 3, 4], [1, 2, 3], { a: 1 }, { a: 1 }, 'hello', null, null]))
</script>

</html>